﻿using MoetutuTranslate.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MoetutuTranslate.TranslateHelper
{
    class OpenWebView
    {
        public static void GetLink(String Mode,string Tag) {
       

            switch (Mode) {
                case "打开P站搜索":
                    try
                    {
                        Convert.ToInt32(Tag);//如果不崩溃，则代表是画师。
                        OpenPixivArt(Tag);
                        return;
                    }
                    catch (Exception ex) {
                        Console.WriteLine("非画师");
                    }
                    OpenPixiv(Tag);
                    break;
                case "打开百度搜索":
                    OpenBaidu(Tag);
                    break;
                case "打开zerochan搜索":

                    OpenZerochan(Tag);
                    break;

            }
        }
        private static void OpenPixivArt(String UserId) {
            string Url = "https://www.pixiv.net/member_illust.php?id=" +UserId;
            OpenBower(Url);


        }
        private static void OpenZerochan(string text)
        {
            string Url = "https://www.zerochan.net/" + HtmlHelper.CodingToUTF8(text);
            OpenBower(Url);
        }

        private static void OpenBaidu(string text)
        {
            string url = "https://www.baidu.com/s?wd=" + text;
            OpenBower(url);

        }

        private static void OpenPixiv(string text)
        {
            string url = string.Format("https://www.pixiv.net/search.php?s_mode=s_tag_full&word={0}&order=popular_d", System.Web.HttpUtility.UrlEncode(text, Encoding.UTF8));
            OpenBower(url);
        }

        private static void OpenBower(string url)
        {
            System.Diagnostics.Process.Start(url);
        }
    }
}
